<?php 
/**
 * 统计操作量
 */
class Module_operate{
	/**
	 * 构造函数
	 */
	function __construct(){
	
	}
	/**
	 * 显示操作量
	 */
	function index(){
		$smarty = loadSmarty();
		loadLib('Operate');
		$type = Operate::getType();//应用名
		/*****************计算时间**********************/
		$time_now=time();
		$time_exp = date("d:H:i:s",$time_now);
		$time_arr = explode(":",$time_exp);
		$time = (($time_arr[1]*60+$time_arr[2])*60+$time_arr[3]);//今天00：00到当前过的秒数
		$week = 7*24*3600;
		$now_time = $time_now-$time;//计算当天00:00
		$last_time= $time_now-3600*24-$time;//计算昨天00:00		
		$next_time= $time_now+3600*24-$time;//计算明天00:00
		$last_week=(int)($time_now/$week);//计算上周第几周
		$now_week=$last_week+1;//计算当前第几周
		$now_week_time = $last_week * $week;//本周初始的秒数
		$last_week_time = $now_week_time - $week;//上周初始的秒数
		$next_week_time = $now_week_time + $week;//本周结束的秒数
		$month = $week*4;//计算一个月的秒数（用30天记作一个月）
		$now_mouth_time = $time_now-$time_arr[0]*24*3600;//本月初始的秒数
		$last_mouth_time = $now_mouth_time - $month;//上月初始的秒数
		$next_mouth_time = $now_mouth_time + $month;//本月结束的秒
		/**********************************************/
		$now_day_count = Operate::getDate($now_time,$next_time);//当天访问人数统计
		$last_day_count = Operate::getDate($last_time,$now_time);//昨天访问人数统计
		$now_week_count = Operate::getDate($now_week_time,$next_week_time);//本周统计
		$last_week_count = Operate::getDate($last_week_time,$now_week_time);//上周统计
		$now_mouth_count = Operate::getDate($now_mouth_time,$next_mouth_time);//本月统计
		$last_mouth_count = Operate::getDate($last_mouth_time,$now_mouth_time);//上月统计
		/*************************把统计数据存到一张表里**********************************/
		$rs=Operate::getArr($type,$now_day_count,"now_day_count");
		$rs=Operate::getArr($rs,$last_day_count,"last_day_count");
		$rs=Operate::getArr($rs,$now_week_count,"now_week_count");
		$rs=Operate::getArr($rs,$last_week_count,"last_week_count");
		$rs=Operate::getArr($rs,$now_mouth_count,"now_mouth_count");
		$rs=Operate::getArr($rs,$last_day_count,"last_day_count");
		$rs=Operate::getArr($rs,$last_mouth_count,"last_mouth_count");
		//print_r($rs);
		/*********************************************************************/
		//echo(count($last_mouth_count[1]));
		$smarty->assign("rs", $rs); //本周访问人数
		return $smarty->fetch('operate/index.tpl.php');
	}
	
	
	function getCountArr(){
		
	}
}
# end of script